#include "camprec.h"

#include "CAMMap.h"

CCAMMap::CCAMMap(void)
{
	AddPage (_T("DEFAULT"));
}

CCAMMap::~CCAMMap(void)
{
}


CMapPage *CCAMMap::AddPage (const wstring &Name)
{
	CMapPage newPage;

	if (Name.empty()) return NULL;
	
	if (GetPage(Name)) return NULL;

	m_CAMMap[Name] = newPage;

	return &m_CAMMap[Name];
}

CMapPage *CCAMMap::GetPage(const wstring &Name)
{
	std::map<wstring, CMapPage>::iterator it;

	if (Name.empty()) return NULL;

	it = m_CAMMap.find (Name);

	if (it!=m_CAMMap.end())
		return &(it->second);

	return NULL;
}

bool CCAMMap::DeletePage(const wstring &Name)
{
	std::map<wstring, CMapPage>::iterator it;

	if (Name.empty())
		return false;

	it = m_CAMMap.find (Name);

	if (it == m_CAMMap.end())
		return false;

	m_CAMMap.erase (it);

	return true;
}

void CCAMMap::Free ()
{
	//m_CAMMap.clear();
	std::map<std::wstring, CMapPage>::iterator it;

	for (it = m_CAMMap.begin(); it != m_CAMMap.end(); it++)
		m_CAMMap.erase (it);
}